#ifndef MAINPAGE_H
#define MAINPAGE_H

#include <QWidget>
class QTimer;
QT_BEGIN_NAMESPACE
namespace Ui { class MainPage; }
QT_END_NAMESPACE

class MainPage : public QWidget
{
    Q_OBJECT

public:
    MainPage(QWidget *parent = nullptr);
    ~MainPage();

private slots:
    void lightTimerTimeoutSlot();
    void modeChangedSlot(int mode);

private:
    void paintEvent(QPaintEvent *);
    void initColor();
    void sendStatus();
    int getRoadIdUseLampId(int lampId);
    /**
     * @brief getLampColorUseLampId
     * @param lampId
     * @return 0-绿色 1-黄色 2-红色 3-白色
     */
    int getLampColorUseLampId(int lampId);

    Ui::MainPage *ui;
    bool showUp = false, showDown = false, showLeft = false, showRight = false;
    QColor group0 = QColor(Qt::green), group1 = QColor(Qt::green);  //0水平方向，1垂直方向
    int upId = -1, downId = -1, leftId = -1, rightId = -1;
    int upRoad, downRoad, leftRoad, rightRoad;

    QTimer *lightTimer;
    QColor group0ColorList[112];
    QColor group1ColorList[112];
    QColor nightColorList[2];
    int index = 0;
    int nightIndex = 0;
    int mode = 0;
};
#endif // MAINPAGE_H
